home *** CD-ROM | disk | FTP | other *** search
/ MacAddict 104 / MacAddict_104_2005-04.iso / Software / Internet & Communication / WordPress 1.2.2 freeware.dmg / wordpress / wp-includes / template-functions-general.php < prev    next >
Encoding:
PHP Script  |  2004-05-18  |  21.0 KB  |  568 lines

  1. <?php
  2.  
  3. /* Note: these tags go anywhere in the template */
  4.  
  5. function bloginfo($show='') {
  6.     $info = get_bloginfo($show);
  7.     $info = apply_filters('bloginfo', $info);
  8.     echo convert_chars($info);
  9. }
  10.  
  11. function bloginfo_rss($show='') {
  12.     $info = strip_tags(get_bloginfo($show));
  13.     echo convert_chars($info);
  14. }
  15.  
  16. function bloginfo_unicode($show='') {
  17.     $info = get_bloginfo($show);
  18.     echo convert_chars($info);
  19. }
  20.  
  21. function get_bloginfo($show='') {
  22.  
  23.     $do_perma = 0;
  24.     $feed_url = get_settings('siteurl');
  25.     $comment_feed_url = get_settings('siteurl');
  26.  
  27.     if ('' != get_settings('permalink_structure')) {
  28.         $do_perma = 1;
  29.         $feed_url = get_settings('home') . '/feed';
  30.         $comment_feed_url = get_settings('home') . '/comments/feed';
  31.     }
  32.  
  33.     switch($show) {
  34.         case 'url':
  35.         case 'siteurl':
  36.             $output = get_settings('home');
  37.             break;
  38.         case 'description':
  39.             $output = get_settings('blogdescription');
  40.             break;
  41.         case 'rdf_url':
  42.             $output = get_settings('siteurl') .'/wp-rdf.php';
  43.             if ($do_perma) {
  44.                 $output = $feed_url . '/rdf/';
  45.             }
  46.             break;
  47.         case 'rss_url':
  48.             $output = get_settings('siteurl') .'/wp-rss.php';
  49.             if ($do_perma) {
  50.                 $output = $feed_url . '/rss/';
  51.             }
  52.             break;
  53.         case 'rss2_url':
  54.             $output = get_settings('siteurl') .'/wp-rss2.php';
  55.             if ($do_perma) {
  56.                 $output = $feed_url . '/rss2/';
  57.             }
  58.             break;
  59.         case 'atom_url':
  60.             $output = get_settings('siteurl') .'/wp-atom.php';
  61.             if ($do_perma) {
  62.                 $output = $feed_url . '/atom/';
  63.             }
  64.             break;        
  65.         case 'comments_rss2_url':
  66.             $output = get_settings('siteurl') .'/wp-commentsrss2.php';
  67.             if ($do_perma) {
  68.                 $output = $comment_feed_url . '/rss2/';
  69.             }
  70.             break;
  71.         case 'pingback_url':
  72.             $output = get_settings('siteurl') .'/xmlrpc.php';
  73.             break;
  74.         case 'admin_email':
  75.             $output = get_settings('admin_email');
  76.             break;
  77.         case 'charset':
  78.             $output = get_settings('blog_charset');
  79.             if ('' == $output) $output = 'UTF-8';
  80.             break;
  81.         case 'version':
  82.             global $wp_version;
  83.             $output = $wp_version;
  84.             break;
  85.         case 'name':
  86.         default:
  87.             $output = get_settings('blogname');
  88.             break;
  89.     }
  90.     return $output;
  91. }
  92.  
  93. function wp_title($sep = '»', $display = true) {
  94.     global $wpdb, $tableposts, $tablecategories;
  95.     global $year, $monthnum, $day, $cat, $p, $name, $month, $posts, $single;
  96.  
  97.     // If there's a category
  98.     if(!empty($cat)) {
  99.         if (!stristr($cat,'-')) { // category excluded
  100.             $title = stripslashes(get_the_category_by_ID($cat));
  101.         }
  102.     }
  103.     if (!empty($category_name)) {
  104.         $title = stripslashes($wpdb->get_var("SELECT cat_name FROM $tablecategories WHERE category_nicename = '$category_name'"));
  105.     }
  106.  
  107.     // If there's a month
  108.     if(!empty($m)) {
  109.         $my_year = substr($m, 0, 4);
  110.         $my_month = $month[substr($m, 4, 2)];
  111.         $title = "$my_year $sep $my_month";
  112.  
  113.     }
  114.     if (!empty($year)) {
  115.         $title = $year;
  116.         if (!empty($monthnum)) {
  117.             $title .= " $sep ".$month[zeroise($monthnum, 2)];
  118.         }
  119.         if (!empty($day)) {
  120.             $title .= " $sep ".zeroise($day, 2);
  121.         }
  122.     }
  123.  
  124.     // If there's a post
  125.     if ($single) {
  126.         $title = strip_tags(stripslashes($posts[0]->post_title));
  127.         $title = apply_filters('single_post_title', $title);
  128.     }
  129.  
  130.     // Send it out
  131.     if ($display && isset($title)) {
  132.         echo " $sep $title";
  133.     } elseif (!$display && isset($title)) {
  134.         return " $sep $title";
  135.     }
  136. }
  137.  
  138. function single_post_title($prefix = '', $display = true) {
  139.     global $p, $name, $wpdb, $tableposts;
  140.     if (intval($p) || '' != $name) {
  141.         if (!$p) {
  142.             $p = $wpdb->get_var("SELECT ID FROM $tableposts WHERE post_name = '$name'");
  143.         }
  144.         $post_data = get_postdata($p);
  145.         $title = $post_data['Title'];
  146.         $title = apply_filters('single_post_title', $title);
  147.         if ($display) {
  148.             echo $prefix.strip_tags(stripslashes($title));
  149.         } else {
  150.             return strip_tags(stripslashes($title));
  151.         }
  152.     }
  153. }
  154.  
  155. function single_cat_title($prefix = '', $display = true ) {
  156.     global $cat;
  157.     if(!empty($cat) && !(strtoupper($cat) == 'ALL')) {
  158.         $my_cat_name = get_the_category_by_ID($cat);
  159.         if(!empty($my_cat_name)) {
  160.             if ($display)
  161.                 echo $prefix.strip_tags(stripslashes($my_cat_name));
  162.             else
  163.                 return strip_tags(stripslashes($my_cat_name));
  164.         }
  165.     }
  166. }
  167.  
  168. function single_month_title($prefix = '', $display = true ) {
  169.     global $m, $month;
  170.     if(!empty($m)) {
  171.         $my_year = substr($m,0,4);
  172.         $my_month = $month[substr($m,4,2)];
  173.         if ($display)
  174.             echo $prefix.$my_month.$prefix.$my_year;
  175.         else
  176.             return $m;
  177.     }
  178. }
  179.  
  180. /* link navigation hack by Orien http://icecode.com/ */
  181. function get_archives_link($url, $text, $format = "html", $before = "", $after = "") {
  182.     if ('link' == $format) {
  183.         return "\t".'<link rel="archives" title="'.$text.'" href="'.$url.'" />'."\n";
  184.     } else if ('option' == $format) {
  185.         return '<option value="'.$url.'">'.$text.'</option>'."\n";
  186.     } else if ('html' == $format) {
  187.         return "\t".'<li><a href="'.$url.'" title="'.$text.'">'.$text.'</a>'.$after.'</li>'."\n";
  188.     } else { // custom
  189.         return "\t".$before.'<a href="'.$url.'" title="'.$text.'">'.$text.'</a>'.$after."\n";
  190.     }
  191. }
  192.  
  193. function wp_get_archives($args = '') {
  194.     parse_str($args, $r);
  195.     if (!isset($r['type'])) $r['type'] = '';
  196.     if (!isset($r['limit'])) $r['limit'] = '';
  197.     if (!isset($r['format'])) $r['format'] = 'html';
  198.     if (!isset($r['before'])) $r['before'] = '';
  199.     if (!isset($r['after'])) $r['after'] = '';
  200.     if (!isset($r['show_post_count'])) $r['show_post_count'] = false;
  201.     get_archives($r['type'], $r['limit'], $r['format'], $r['before'], $r['after'], $r['show_post_count']);
  202. }
  203.  
  204. function get_archives($type='', $limit='', $format='html', $before = '', $after = '', $show_post_count = false) {
  205.     global $tableposts;
  206.     global $querystring_start, $querystring_equal, $querystring_separator, $month, $wpdb;
  207.  
  208.     if ('' == $type) {
  209.         $type = get_settings('archive_mode');
  210.     }
  211.  
  212.     if ('' != $limit) {
  213.         $limit = (int) $limit;
  214.         $limit = ' LIMIT '.$limit;
  215.     }
  216.     // this is what will separate dates on weekly archive links
  217.     $archive_week_separator = '–';
  218.  
  219.     // archive link url
  220.     $archive_link_m = get_settings('siteurl').'/'.get_settings('blogfilename').$querystring_start.'m'.$querystring_equal;    # monthly archive;
  221.     $archive_link_w = get_settings('siteurl').'/'.get_settings('blogfilename').$querystring_start.'w'.$querystring_equal;    # weekly archive;
  222.     $archive_link_p = get_settings('siteurl').'/'.get_settings('blogfilename').$querystring_start.'p'.$querystring_equal;    # post-by-post archive;
  223.  
  224.     // over-ride general date format ? 0 = no: use the date format set in Options, 1 = yes: over-ride
  225.     $archive_date_format_over_ride = 0;
  226.  
  227.     // options for daily archive (only if you over-ride the general date format)
  228.     $archive_day_date_format = 'Y/m/d';
  229.  
  230.     // options for weekly archive (only if you over-ride the general date format)
  231.     $archive_week_start_date_format = 'Y/m/d';
  232.     $archive_week_end_date_format   = 'Y/m/d';
  233.  
  234.     if (!$archive_date_format_over_ride) {
  235.         $archive_day_date_format = get_settings('date_format');
  236.         $archive_week_start_date_format = get_settings('date_format');
  237.         $archive_week_end_date_format = get_settings('date_format');
  238.     }
  239.  
  240.     $add_hours = intval(get_settings('gmt_offset'));
  241.     $add_minutes = intval(60 * (get_settings('gmt_offset') - $add_hours));
  242.  
  243.     $now = current_time('mysql');
  244.  
  245.     if ('monthly' == $type) {
  246.         $arcresults = $wpdb->get_results("SELECT DISTINCT YEAR(post_date) AS `year`, MONTH(post_date) AS `month`, count(ID) as posts FROM $tableposts WHERE post_date < '$now' AND post_status = 'publish' GROUP BY YEAR(post_date), MONTH(post_date) ORDER BY post_date DESC" . $limit);
  247.         if ($arcresults) {
  248.             $afterafter = $after;
  249.             foreach ($arcresults as $arcresult) {
  250.                 $url  = get_month_link($arcresult->year,   $arcresult->month);
  251.                 if ($show_post_count) {
  252.                     $text = sprintf('%s %d', $month[zeroise($arcresult->month,2)], $arcresult->year);
  253.                     $after = ' ('.$arcresult->posts.')' . $afterafter;
  254.                 } else {
  255.                     $text = sprintf('%s %d', $month[zeroise($arcresult->month,2)], $arcresult->year);
  256.                 }
  257.                 echo get_archives_link($url, $text, $format, $before, $after);
  258.             }
  259.         }
  260.     } elseif ('daily' == $type) {
  261.         $arcresults = $wpdb->get_results("SELECT DISTINCT YEAR(post_date) AS `year`, MONTH(post_date) AS `month`, DAYOFMONTH(post_date) AS `dayofmonth` FROM $tableposts WHERE post_date < '$now' AND post_status = 'publish' ORDER BY post_date DESC" . $limit);
  262.         if ($arcresults) {
  263.             foreach ($arcresults as $arcresult) {
  264.                 $url  = get_day_link($arcresult->year, $arcresult->month, $arcresult->dayofmonth);
  265.                 $date = sprintf("%d-%02d-%02d 00:00:00", $arcresult->year, $arcresult->month, $arcresult->dayofmonth);
  266.                 $text = mysql2date($archive_day_date_format, $date);
  267.                 echo get_archives_link($url, $text, $format, $before, $after);
  268.             }
  269.         }
  270.     } elseif ('weekly' == $type) {
  271.     $start_of_week = get_settings('start_of_week');
  272.         $arcresults = $wpdb->get_results("SELECT DISTINCT WEEK(post_date, $start_of_week) AS `week`, YEAR(post_date) AS yr, DATE_FORMAT(post_date, '%Y-%m-%d') AS yyyymmdd FROM $tableposts WHERE post_date < '$now' AND post_status = 'publish' ORDER BY post_date DESC" . $limit);
  273.         $arc_w_last = '';
  274.         if ($arcresults) {
  275.             foreach ($arcresults as $arcresult) {
  276.                 if ($arcresult->week != $arc_w_last) {
  277.                     $arc_year = $arcresult->yr;
  278.                     $arc_w_last = $arcresult->week;
  279.                     $arc_week = get_weekstartend($arcresult->yyyymmdd, get_settings('start_of_week'));
  280.                     $arc_week_start = date_i18n($archive_week_start_date_format, $arc_week['start']);
  281.                     $arc_week_end = date_i18n($archive_week_end_date_format, $arc_week['end']);
  282.                     $url  = sprintf('%s/%s%sm%s%s%sw%s%d', get_settings('home'), get_settings('blogfilename'), $querystring_start,
  283.                                     $querystring_equal, $arc_year, $querystring_separator,
  284.                                     $querystring_equal, $arcresult->week);
  285.                     $text = $arc_week_start . $archive_week_separator . $arc_week_end;
  286.                     echo get_archives_link($url, $text, $format, $before, $after);
  287.                 }
  288.             }
  289.         }
  290.     } elseif ('postbypost' == $type) {
  291.         $arcresults = $wpdb->get_results("SELECT ID, post_date, post_title FROM $tableposts WHERE post_date < '$now' AND post_status = 'publish' ORDER BY post_date DESC" . $limit);
  292.         if ($arcresults) {
  293.             foreach ($arcresults as $arcresult) {
  294.                 if ($arcresult->post_date != '0000-00-00 00:00:00') {
  295.                     $url  = get_permalink($arcresult->ID);
  296.                     $arc_title = stripslashes($arcresult->post_title);
  297.                     if ($arc_title) {
  298.                         $text = strip_tags($arc_title);
  299.                     } else {
  300.                         $text = $arcresult->ID;
  301.                     }
  302.                     echo get_archives_link($url, $text, $format, $before, $after);
  303.                 }
  304.             }
  305.         }
  306.     }
  307. }
  308.  
  309. function get_calendar($daylength = 1) {
  310.     global $wpdb, $m, $monthnum, $year, $timedifference, $month, $month_abbrev, $weekday, $weekday_initial, $weekday_abbrev, $tableposts, $posts;
  311.  
  312.     // Quick check. If we have no posts at all, abort!
  313.     if (!$posts) {
  314.         $gotsome = $wpdb->get_var("SELECT ID from $tableposts WHERE post_status = 'publish' ORDER BY post_date DESC LIMIT 1");
  315.         if (!$gotsome)
  316.             return;
  317.     }
  318.  
  319.     if (isset($_GET['w'])) {
  320.         $w = ''.intval($_GET['w']);
  321.     }
  322.  
  323.     $add_hours = intval(get_settings('gmt_offset'));
  324.     $add_minutes = intval(60 * (get_settings('gmt_offset') - $add_hours));
  325.  
  326.     // Let's figure out when we are
  327.     if (!empty($monthnum) && !empty($year)) {
  328.         $thismonth = ''.zeroise(intval($monthnum), 2);
  329.         $thisyear = ''.intval($year);
  330.     } elseif (!empty($w)) {
  331.         // We need to get the month from MySQL
  332.         $thisyear = ''.intval(substr($m, 0, 4));
  333.         $d = (($w - 1) * 7) + 6; //it seems MySQL's weeks disagree with PHP's
  334.         $thismonth = $wpdb->get_var("SELECT DATE_FORMAT((DATE_ADD('${thisyear}0101', INTERVAL $d DAY) ), '%m')");
  335.     } elseif (!empty($m)) {
  336.         $calendar = substr($m, 0, 6);
  337.         $thisyear = ''.intval(substr($m, 0, 4));
  338.         if (strlen($m) < 6) {
  339.             $thismonth = '01';
  340.         } else {
  341.             $thismonth = ''.zeroise(intval(substr($m, 4, 2)), 2);
  342.         }
  343.     } else {
  344.         $thisyear = gmdate('Y', current_time('timestamp') + get_settings('gmt_offset') * 3600);
  345.         $thismonth = gmdate('m', current_time('timestamp') + get_settings('gmt_offset') * 3600);
  346.     }
  347.  
  348.     $unixmonth = mktime(0, 0 , 0, $thismonth, 1, $thisyear);
  349.  
  350.     // Get the next and previous month and year with at least one post
  351.     $previous = $wpdb->get_row("SELECT DISTINCT MONTH(post_date) AS month, YEAR(post_date) AS year
  352.             FROM $tableposts
  353.             WHERE post_date < '$thisyear-$thismonth-01'
  354.             AND post_status = 'publish'
  355.                               ORDER BY post_date DESC
  356.                               LIMIT 1");
  357.     $next = $wpdb->get_row("SELECT  DISTINCT MONTH(post_date) AS month, YEAR(post_date) AS year
  358.             FROM $tableposts
  359.             WHERE post_date >  '$thisyear-$thismonth-01'
  360.             AND MONTH( post_date ) != MONTH( '$thisyear-$thismonth-01' )
  361.             AND post_status = 'publish'
  362.                               ORDER  BY post_date ASC
  363.                               LIMIT 1");
  364.  
  365.     echo '<table id="wp-calendar">
  366.     <caption>' . $month[zeroise($thismonth, 2)] . ' ' . date('Y', $unixmonth) . '</caption>
  367.     <thead>
  368.     <tr>';
  369.  
  370.     $day_abbrev = $weekday_initial;
  371.     if ($daylength > 1) {
  372.         $day_abbrev = $weekday_abbrev;
  373.     }
  374.  
  375.     foreach ($weekday as $wd) {
  376.         echo "\n\t\t<th abbr=\"$wd\" scope=\"col\" title=\"$wd\">" . $day_abbrev[$wd] . '</th>';
  377.     }
  378.  
  379.     echo '
  380.     </tr>
  381.     </thead>
  382.  
  383.     <tfoot>
  384.     <tr>';
  385.  
  386.     if ($previous) {
  387.         echo "\n\t\t".'<td abbr="' . $month[zeroise($previous->month, 2)] . '" colspan="3" id="prev"><a href="' .
  388.             get_month_link($previous->year, $previous->month) . '" title="' . sprintf(__('View posts for %1$s %2$s'), $month[zeroise($previous->month, 2)], date('Y', mktime(0, 0 , 0, $previous->month, 1, $previous->year))) . '">« ' . $month_abbrev[$month[zeroise($previous->month, 2)]] . '</a></td>';
  389.     } else {
  390.         echo "\n\t\t".'<td colspan="3" id="prev" class="pad"> </td>';
  391.     }
  392.  
  393.     echo "\n\t\t".'<td class="pad"> </td>';
  394.  
  395.     if ($next) {
  396.         echo "\n\t\t".'<td abbr="' . $month[zeroise($next->month, 2)] . '" colspan="3" id="next"><a href="' .
  397.                 get_month_link($next->year, $next->month) . '" title="View posts for ' . $month[zeroise($next->month, 2)] . ' ' .
  398.                 date('Y', mktime(0, 0 , 0, $next->month, 1, $next->year)) . '">' . substr($month[zeroise($next->month, 2)], 0, 3) . ' »</a></td>';
  399.     } else {
  400.         echo "\n\t\t".'<td colspan="3" id="next" class="pad"> </td>';
  401.     }
  402.  
  403.     echo '
  404.     </tr>
  405.     </tfoot>
  406.  
  407.     <tbody>
  408.     <tr>';
  409.  
  410.     // Get days with posts
  411.     $dayswithposts = $wpdb->get_results("SELECT DISTINCT DAYOFMONTH(post_date)
  412.             FROM $tableposts WHERE MONTH(post_date) = $thismonth
  413.             AND YEAR(post_date) = $thisyear
  414.             AND post_status = 'publish'
  415.             AND post_date < '" . current_time('mysql') . '\'', ARRAY_N);
  416.     if ($dayswithposts) {
  417.         foreach ($dayswithposts as $daywith) {
  418.             $daywithpost[] = $daywith[0];
  419.         }
  420.     } else {
  421.         $daywithpost = array();
  422.     }
  423.  
  424.  
  425.  
  426.     if (strstr($_SERVER['HTTP_USER_AGENT'], 'MSIE') ||
  427.           strstr(strtolower($_SERVER['HTTP_USER_AGENT']), 'camino') ||
  428.           strstr(strtolower($_SERVER['HTTP_USER_AGENT']), 'safari')) {
  429.         $ak_title_separator = "\n";
  430.     } else {
  431.         $ak_title_separator = ', ';
  432.     }
  433.  
  434.     $ak_titles_for_day = array();
  435.     $ak_post_titles = $wpdb->get_results("SELECT post_title, DAYOFMONTH(post_date) as dom "
  436.                                          ."FROM $tableposts "
  437.                                          ."WHERE YEAR(post_date) = '$thisyear' "
  438.                                          ."AND MONTH(post_date) = '$thismonth' "
  439.                                          ."AND post_date < '".current_time('mysql')."' "
  440.                                          ."AND post_status = 'publish'"
  441.                                         );
  442.     if ($ak_post_titles) {
  443.         foreach ($ak_post_titles as $ak_post_title) {
  444.             if (empty($ak_titles_for_day['day_'.$ak_post_title->dom])) {
  445.                 $ak_titles_for_day['day_'.$ak_post_title->dom] = '';
  446.             }
  447.             if (empty($ak_titles_for_day["$ak_post_title->dom"])) { // first one
  448.                 $ak_titles_for_day["$ak_post_title->dom"] = htmlspecialchars(stripslashes($ak_post_title->post_title));
  449.             } else {
  450.                 $ak_titles_for_day["$ak_post_title->dom"] .= $ak_title_separator . htmlspecialchars(stripslashes($ak_post_title->post_title));
  451.             }
  452.         }
  453.     }
  454.  
  455.  
  456.     // See how much we should pad in the beginning
  457.     $pad = intval(date('w', $unixmonth));
  458.     if (0 != $pad) echo "\n\t\t".'<td colspan="'.$pad.'" class="pad"> </td>';
  459.  
  460.     $daysinmonth = intval(date('t', $unixmonth));
  461.     for ($day = 1; $day <= $daysinmonth; ++$day) {
  462.         if (isset($newrow) && $newrow)
  463.             echo "\n\t</tr>\n\t<tr>\n\t\t";
  464.         $newrow = false;
  465.  
  466.         if ($day == gmdate('j', (time() + (get_settings('gmt_offset') * 3600))) && $thismonth == gmdate('m', time()+(get_settings('gmt_offset') * 3600)))
  467.             echo '<td id="today">';
  468.         else
  469.             echo '<td>';
  470.  
  471.         if (in_array($day, $daywithpost)) { // any posts today?
  472.             echo '<a href="' . get_day_link($thisyear, $thismonth, $day) . "\" title=\"$ak_titles_for_day[$day]\">$day</a>";
  473.         } else {
  474.             echo $day;
  475.         }
  476.         echo '</td>';
  477.  
  478.         if (6 == date('w', mktime(0, 0 , 0, $thismonth, $day, $thisyear)))
  479.             $newrow = true;
  480.     }
  481.  
  482.     $pad = 7 - date('w', mktime(0, 0 , 0, $thismonth, $day, $thisyear));
  483.     if ($pad != 0 && $pad != 7)
  484.         echo "\n\t\t".'<td class="pad" colspan="'.$pad.'"> </td>';
  485.  
  486.     echo "\n\t</tr>\n\t</tbody>\n\t</table>";
  487. }
  488.  
  489. function allowed_tags() {
  490.     global $allowedtags;
  491.     $allowed = '';
  492.     foreach($allowedtags as $tag => $attributes) {
  493.         $allowed .= '<'.$tag;
  494.         if (0 < count($attributes)) {
  495.             foreach ($attributes as $attribute => $limits) {
  496.                 $allowed .= ' '.$attribute.'=""';
  497.             }
  498.         }
  499.         $allowed .= '> ';
  500.     }
  501.     return htmlentities($allowed);
  502. }
  503.  
  504. /***** Date/Time tags *****/
  505.  
  506. function the_date_xml() {
  507.     global $post;
  508.     echo mysql2date('Y-m-d', $post->post_date);
  509.     //echo ""+$post->post_date;
  510. }
  511.  
  512. function the_date($d='', $before='', $after='', $echo = true) {
  513.     global $id, $post, $day, $previousday, $newday;
  514.     $the_date = '';
  515.     if ($day != $previousday) {
  516.         $the_date .= $before;
  517.         if ($d=='') {
  518.         $the_date .= mysql2date(get_settings('date_format'), $post->post_date);
  519.         } else {
  520.         $the_date .= mysql2date($d, $post->post_date);
  521.         }
  522.         $the_date .= $after;
  523.         $previousday = $day;
  524.     }
  525.     $the_date = apply_filters('the_date', $the_date);
  526.     if ($echo) {
  527.         echo $the_date;
  528.     } else {
  529.         return $the_date;
  530.     }
  531. }
  532.  
  533. function the_time($d='', $echo = true) {
  534.     global $id, $post;
  535.     if ($d=='') {
  536.         $the_time = mysql2date(get_settings('time_format'), $post->post_date);
  537.     } else {
  538.         $the_time = mysql2date($d, $post->post_date);
  539.     }
  540.     $the_time = apply_filters('the_time', $the_time);
  541.     if ($echo) {
  542.         echo $the_time;
  543.     } else {
  544.         return $the_time;
  545.     }
  546. }
  547.  
  548. function the_weekday() {
  549.     global $weekday, $id, $post;
  550.     $the_weekday = $weekday[mysql2date('w', $post->post_date)];
  551.     $the_weekday = apply_filters('the_weekday', $the_weekday);
  552.     echo $the_weekday;
  553. }
  554.  
  555. function the_weekday_date($before='',$after='') {
  556.     global $weekday, $id, $post, $day, $previousweekday;
  557.     $the_weekday_date = '';
  558.     if ($day != $previousweekday) {
  559.         $the_weekday_date .= $before;
  560.         $the_weekday_date .= $weekday[mysql2date('w', $post->post_date)];
  561.         $the_weekday_date .= $after;
  562.         $previousweekday = $day;
  563.     }
  564.     $the_weekday_date = apply_filters('the_weekday_date', $the_weekday_date);
  565.     echo $the_weekday_date;
  566. }
  567.  
  568. ?>